const fetch = require("node-fetch");
var Mock = require("mockjs");
const dayjs = require("dayjs");
// Import the v4 function from the uuid package
const { v4: uuidv4 } = require("uuid");
function getRandomIntInclusive(min, max) {
  const minCeiled = Math.ceil(min);
  const maxFloored = Math.floor(max);
  return Math.floor(Math.random() * (maxFloored - minCeiled + 1) + minCeiled);
}
const billlist = async (ctx, next) => {
  var data = {
    list: new Array(20).fill({}).map((it, index) => {
      const uuid = uuidv4();
      return {
        ...it,
        id: uuid,
        companyName: "天合光能股份有限公司" + index + 1,
        dateFrom: dayjs().format("YYYY-MM-DD HH:mm:ss"),
        dateTo: dayjs().add(7, "day").format("YYYY-MM-DD HH:mm:ss"),
        location: [1, 2, 3, 4, 5, 6],
        billNo: "JD" + new Date().getTime(),
        status: getRandomIntInclusive(-1, 6),
      };
    }),
  };

  ctx.response.body = {
    status: 1,
    data: data,
  };
};

billlist.method = "get";
billlist.name = "billlist";

module.exports = billlist;
